<template>
  <div class="records">
    <div class="top-title">经销商</div>
    <div class="top-radio">
      <el-radio-group v-model="topRadio">
        <el-radio-button label="0">全部</el-radio-button>
        <el-radio-button label="3">自定义</el-radio-button>
      </el-radio-group>
      <el-date-picker
        v-model="topDate"
        type="daterange"
        range-separator="至"
        start-placeholder="开始日期"
        end-placeholder="结束日期"
        style="margin-left: 200px"
        :disabled="topRadio == 0"
      >
      </el-date-picker>
    </div>
    <div class="mid-context">
      <div class="left-context">
        <el-table :data="tableData" border style="margin-top: 20px">
          <el-table-column prop="date" label="战队名称" :align="tableAlign"> </el-table-column>
          <el-table-column prop="date" label="资源数" :align="tableAlign"> </el-table-column>
          <el-table-column prop="name" label="已合作" :align="tableAlign"> </el-table-column>
          <el-table-column prop="address" label="停止合作" :align="tableAlign"> </el-table-column>
          <el-table-column prop="address" label="经销商总数" :align="tableAlign"> </el-table-column>
        </el-table>
      </div>
      <div class="right-context">
        <div id="allMain" style="height: 600px"></div>
      </div>
    </div>
  </div>
</template>
<script>
import * as echarts from "echarts";
export default {
  data() {
    return {
      topRadio: "0",
      topDate: "",
      tableAlign:'center',
    };
  },
  methods: {
    initCharts() {
      var chartDom = document.getElementById("allMain");
      var myChart = echarts.init(chartDom);
      var option;

      option = {
        tooltip: {
          trigger: "item",
        },
        legend: {
          top: "5%",
          left: "center",
          selectedMode: false,
        },
        series: [
          {
            name: "Access From",
            type: "pie",
            radius: ["40%", "70%"],
            avoidLabelOverlap: false,
            padAngle: 5,
            itemStyle: {
              borderRadius: 10,
            },
            label: {
              normal: {
                show: true,
                position: "inner", // 数值显示在内部
                formatter: "{d}%", // 格式化数值百分比输出
              },
            },
            emphasis: {
              label: {
                show: true,
                fontSize: 40,
                fontWeight: "bold",
              },
            },
            labelLine: {
              show: false,
            },
            data: [
              { value: 1048, name: "Search Engine" },
              { value: 735, name: "Direct" },
              { value: 580, name: "Email" },
              { value: 484, name: "Union Ads" },
              { value: 300, name: "Video Ads" },
            ],
          },
        ],
      };

      option && myChart.setOption(option);
      window.addEventListener('resize', function () {
                    myChart.resize();
                });
    },
  },
  mounted() {
    this.initCharts();
  },
};
</script>
<style lang="scss" scoped>
.records {
  margin-top: 30px;
  width: 100%;

  .top-title {
    border-left: 8px solid #409eff;
    margin: 20px 0;
    padding: 3px 0 3px 25px;
    font-size: 18px;
    font-weight: bold;
  }

  .top-radio {
    display: flex;
    justify-content: center;
  }

  .mid-context {
    width: 100%;
    display: flex;
    justify-content: space-between;
    margin-top: 20px;

    .left-context {
      width: 47%;
    }

    .right-context {
      width: 47%;

      .right-button {
        display: flex;
        justify-content: space-between;
        align-items: center;
      }
    }
  }
}
</style>
